package com.tiny.pong;

import java.awt.Color;
import java.awt.Graphics2D;

import com.tiny.core.game.util.MovimentCalculator;
import com.tiny.core.physics.PhysicGameObject;

public class Ball extends PhysicGameObject {

    public Ball(int x, int y, int width, int height, MovimentCalculator calc) {
        super(x, y, width, height, calc);
    }

    @Override
    public void render(Graphics2D g) {
        g.setColor(Color.LIGHT_GRAY);
        g.fillOval((int)pos.x, (int)pos.y, (int)pos.width, (int)pos.height);
    }

    @Override
    public void onUpdate(int currentTick) {
        if (isCollingAbove() || isCollingBelow()) {
            invertVelocityY();
        } else if (isCollingLeft() || isCollingRight()) {
            invertVelocityX();
        }
    }
}
